<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>预约须知</title>

    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <link rel="stylesheet" href="../css/page-health-orderInfo.css"/>
    <link rel="stylesheet" href="../plugins/elementui/index.css"/>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/Math.uuid.js"></script>
    <script src="../plugins/datapicker/datePicker.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }

        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>

<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>预约管理
            <small>预约列表</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>预约管理</el-breadcrumb-item>
            <el-breadcrumb-item>预约列表</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="下单人" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                <el-button @click="findPages()" class="dalfBut">预约查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()">新建预约</el-button>
            </div>
            <!--Table 表格-->
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="memberId" label="会员编码" align="center"></el-table-column>
                <el-table-column prop="name" label="会员姓名" align="center"></el-table-column>
                <el-table-column prop="orderDate" label="下单日期" align="center"></el-table-column>
                <el-table-column prop="orderType" label="下单类型" align="center"></el-table-column>
                <el-table-column prop="orderStatus" label="下单状态" align="center"></el-table-column>
                <el-table-column prop="setmealId" label="套餐编码" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除订单</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <!--Pagination 分页-->
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 新增标签弹层 -->
            <div class="add-form">
                <!--Dialog 对话框-->
                <el-dialog title="新增电话预约" :visible.sync="dialogFormVisible">
                    <template>
                        <!--Tabs 标签页-->
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="基本信息" name="first">
                                <!--Form 表单-->
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="姓名">
                                                <el-input v-model="formData.name"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="身份证号">
                                                <el-input v-model="formData.idCard"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="性别">
                                                <el-select v-model="formData.sex">
                                                    <el-option label="不限" value="0"></el-option>
                                                    <el-option label="男" value="1"></el-option>
                                                    <el-option label="女" value="2"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="手机号">
                                                <el-input v-model="formData.telephone"/>
                                            </el-form-item>
                                            <input style="font-size: x-small;" id="validateCodeButton"
                                                   @click="sendValidateCode()" type="button"
                                                   value="发送验证码">
                                        </el-col>
                                    </el-row>
                                    <el-low>
                                        <template>
                                            <div class="block">
                                                <span class="demonstration">默认</span>
                                                <el-date-picker
                                                        v-model="formData.orderDate"
                                                        type="date"
                                                        placeholder="选择日期">
                                                </el-date-picker>
                                            </div>
                                        </template>
                                        <template>
                                            <div class="input-row">
                                                <label>验证码</label>
                                                <input v-model="formData.validateCode" type="text" class="input-clear"
                                                       placeholder="请输入验证码">
                                            </div>
                                        </template>
                                    </el-low>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="套餐信息" name="second">
                                <div class="checkScrol">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>选择</th>
                                            <th>套餐编码</th>
                                            <th>套餐名称</th>
                                            <th>套餐说明</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <!--tableData所有检查项-->
                                        <tr v-for="c in tableData">
                                            <td>
                                                <input :id="c.id" v-model="setmealIds" type="checkbox" :value="c.id">
                                                <!--                                                <h5>检查项的id:{{checkitemIds}}</h5>-->
                                            </td>
                                            <td><label :for="c.id">{{c.code}}</label></td>
                                            <td><label :for="c.id">{{c.name}}</label></td>
                                            <td><label :for="c.id">{{c.remark}}</label></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                        <el-button type="primary" @click="handleAdd()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            activeName: 'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize: 10,
                total: 0,
                queryString: null,
            },
            dataList: [],//列表数据
            formData: {},//表单数据
            tableData: [],//新增和编辑表单中对应的检查项列表数据
            setmealIds: [],//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit: false//控制编辑窗口显示/隐藏
        },
        created() {
            this.findPages();
        },
        methods: {
            //发送验证码
            sendValidateCode() {
                //获取用户输入的手机号
                var telephone = this.formData.telephone;
                //校验手机号输入是否正确
                if (!checkTelephone(telephone)) {
                    this.$message.error('请输入正确的手机号');
                    return false;
                }
                validateCodeButton = $("#validateCodeButton")[0];
                clock = window.setInterval(doLoop, 1000); //一秒执行一次
                axios.post("/checkgroupYY/send4Order.do?telephone=" + telephone).then((response) => {
                    if (!response.data.flag) {
                        //验证码发送失败
                        this.$message.error('验证码发送失败，请检查手机号输入是否正确');
                    }
                });
            },
            //添加
            handleAdd() {
                //提交formData setmealIds
                this.formData.setmealIds = this.setmealIds;
                axios.post("/checkgroupYY/addYY.do", this.formData)
                    .then((res) => {
                        this.dialogFormVisible = false;
                        this.findPages();
                    });
            },
            //分页查询
            findPages() {
                axios.post("/checkgroupYY/findPages.do", this.pagination)
                    .then((res) => {
                        this.pagination.total = res.data.total;
                        this.dataList = res.data.rows;
                    });
            },
            // 重置表单
            resetForm() {
                this.activeName = 'first';
                this.formData = {};
                this.checkitemIds = [];
            },
            // 弹出添加窗口
            handleCreate() {
                this.resetForm();
                axios.get("/checkgroupYY/findAll.do")
                    .then((res) => {
                        console.log(res);
                        this.tableData = res.data.data;
                        this.dialogFormVisible = true;
                    });
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPages();
            },
            // 删除
            handleDelete(row) {
                axios.post("/checkgroupYY/delete.do", row).then((res) => {
                        this.$message.success(res.data.message);
                        this.findPages();
                    }
                );

            }
        }
    })
</script>
</html>